<?php

namespace Biz\model\springHomeDecActivity;

use Biz\model\advertisement\MBaseDbModel;
use Biz\pockets\modelTrait\BizModelTrait;

/**
 * @property mixed|null $product_id
 * @property mixed|null $product_type
 * @property mixed|null $product_pic
 * @property mixed|null $product_name
 * @property mixed|null $winning_record_id
 * @property mixed|null $product_value
 * @property mixed|null $total
 * @property mixed|null $num
 */
class MSpringHomeDecProduct extends MBaseDbModel
{
    const _CONFIG_FILE_ = 'db_store';
    
    const _CONFIG_SELECT_ = 'db_brand_activity';
    
    const _DATABASE_ = 'brand_activity';
    
    const _TABLE_NAME = 'spring_home_dec_product';

    const PRODUCT_TYPE_WIKI = 1;
    const PRODUCT_TYPE_SERVICE = 2;

    //删除字段名称
    protected static $deleteField = 'status';

    use BizModelTrait;

    public static function getV($product_id)
    {
        return self::dataSelectInfo(['product_id' => $product_id], ['v']);
    }

    public static function decreaseStock($product_id, $v)
    {
        return self::dataUpdate(['num[-]' => 1, 'update_time' => date("Y-m-d H:i:s"), 'v[+]' => 1], ['product_id' => $product_id, 'v' => $v, 'num[>]' => 0], true);
    }
}
